<?php 
  require(dirname(__FILE__).'/global.php');
  $filename = $_POST['filename'];
  if(empty($filename)){
      echo json_encode('文件不存在');
  }
  else{
      $file = ROOT."/admin/menu/$filename.xml";                                                
      if(file_exists($file)){
          require(ROOT.'/include/xml.class.php');
          $array = array();
          $array2 = array();
          $xml = new DOMDocument();
          $xml->load($file);
          $menus = $xml->getElementsByTagName('menu');  
          foreach($menus as $menu){
              $titles = $menu->getElementsByTagName('title');
              $title = $titles->item(0)->nodeValue; 
              
              $urls = $menu->getElementsByTagName('url');
              $url = $urls->item(0)->nodeValue;  
              
              $array2['title'] = $title;
              $array2['url'] = $url;
              $array[] = $array2;
          }
          echo json_encode($array);
      }
      else{
          echo json_encode('文件不存在');
      }
  }                               
?>
